package my.cn.bdqn.life;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.TabHost;

public class TabPlayActivity extends TabActivity {
	TabHost tabHost;
    private static final String SING="SING";
    private static final String MUSIC="MUSIC";
    private static final String DRAMA="DRAMA";
    private static final String TRA="TRA";
    RadioButton rb1,rb2,rb3,rb4;
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabplay_layout);
		View view1=getLayoutInflater().inflate(R.layout.tabs_sing_play, null);
		View view2=getLayoutInflater().inflate(R.layout.tabs_music_play, null);
		View view3=getLayoutInflater().inflate(R.layout.tabs_drama_play, null);
		View view4=getLayoutInflater().inflate(R.layout.tabs_tra_play, null);
		rb1=(RadioButton) view1.findViewById(R.id.rb);
		rb2=(RadioButton) view2.findViewById(R.id.rb);;
		rb3=(RadioButton) view3.findViewById(R.id.rb);
		rb4=(RadioButton) view4.findViewById(R.id.rb);;
		tabHost=getTabHost();
		tabHost.addTab(tabHost.newTabSpec(SING).setIndicator(view1).setContent(new Intent(this,SingPlayActivity.class)));
		tabHost.addTab(tabHost.newTabSpec(MUSIC).setIndicator(view2).setContent(new Intent(this,MusicPlayActivity.class)));
		tabHost.addTab(tabHost.newTabSpec(DRAMA).setIndicator(view3).setContent(new Intent(this,DramaPlayActivity.class)));
		tabHost.addTab(tabHost.newTabSpec(TRA).setIndicator(view4).setContent(new Intent(this,TraPlayActivity.class)));		
		tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
			
			public void onTabChanged(String tab) {
				// TODO Auto-generated method stub
				if(tab.equals(SING)){
					rb1.setChecked(true);
					rb2.setChecked(false);
					rb3.setChecked(false);
					rb4.setChecked(false);
				}else if(tab.equals(MUSIC)){
					rb1.setChecked(false);
					rb2.setChecked(true);
					rb3.setChecked(false);
					rb4.setChecked(false);
				}
				else if(tab.equals(DRAMA)){
					rb1.setChecked(false);
					rb2.setChecked(false);
					rb3.setChecked(true);
					rb4.setChecked(false);
				}else if(tab.equals(TRA)){
					rb1.setChecked(false);
					rb2.setChecked(false);
					rb3.setChecked(false);
					rb4.setChecked(true);
				}
			}
		});
		rb1.setChecked(true);
	}
	
}
